import { useMemoizedFn } from 'ahooks';
import { memo, useState } from 'react';
import { Position } from '../../../../store';

interface MeasureItem {
    id: string;

    points: Position[];
}

const Measure = () => {
    const [measureData, setMeasureData] = useState<MeasureItem[]>([]);

    const updateMeasure = useMemoizedFn((data: MeasureItem) => {
        const { id, points } = data;
        setMeasureData((list) => {
            const index = list.findIndex((item) => item.id === id);
            if (index !== -1) {
                list[index].points = points;
            }
            return [...list];
        });
    });

    const updateMeasure = useMemoizedFn((data: MeasureItem) => {
        const { id, points } = data;
        setMeasureData((list) => {
            const index = list.findIndex((item) => item.id === id);
            if (index !== -1) {
                list[index].points = points;
            }
            return [...list];
        });
    });

    return <></>;
};

export default memo(Measure);
